package com.example.seabedmusic.entity;

import android.os.Parcel;
import android.os.Parcelable;

import androidx.annotation.NonNull;

public class HotSong  implements Parcelable {
    private String id;
    private String name;        // 歌曲名
    private String author;      // 歌手
    private String cover;       // 封面
    private String hash;        // 歌曲哈希值，用于播放
    private int rank;           // 排名
    private String album;       // 专辑名
    private String duration;    // 时长
    private String lyrics;      // 歌词
    private String url;    //播放路径

    // 默认构造函数
    public HotSong() {
    }

    // 简化构造函数
    public HotSong(String name, String author) {
        this.name = name;
        this.author = author;
    }

    // 完整构造函数
    public HotSong(String id, String name, String author, String cover, String hash, int rank) {
        this.id = id;
        this.name = name;
        this.author = author;
        this.cover = cover;
        this.hash = hash;
        this.rank = rank;
    }

    protected HotSong(Parcel in) {
        id = in.readString();
        name = in.readString();
        author = in.readString();
        cover = in.readString();
        hash = in.readString();
        rank = in.readInt();
        album = in.readString();
        duration = in.readString();
        lyrics = in.readString();
        url = in.readString();
    }

    public static final Creator<HotSong> CREATOR = new Creator<HotSong>() {
        @Override
        public HotSong createFromParcel(Parcel in) {
            return new HotSong(in);
        }

        @Override
        public HotSong[] newArray(int size) {
            return new HotSong[size];
        }
    };

    /* Getter */
    public String getId() { return id; }
    public String getName() { return name; }
    public String getAuthor() { return author; }
    public String getCover() { return cover; }
    public String getHash() { return hash; }
    public int getRank() { return rank; }
    public String getAlbum() { return album; }
    public String getDuration() { return duration; }
    public String getLyrics() { return lyrics; }
    public String getUrl() { return url; }

    /* Setter */
    public void setId(String id) { this.id = id; }
    public void setName(String name) { this.name = name; }
    public void setAuthor(String author) { this.author = author; }
    public void setCover(String cover) { this.cover = cover; }
    public void setHash(String hash) { this.hash = hash; }
    public void setRank(int rank) { this.rank = rank; }
    public void setAlbum(String album) { this.album = album; }
    public void setDuration(String duration) { this.duration = duration; }
    public void setLyrics(String lyrics) { this.lyrics = lyrics; }
    public void setUrl(String url) { this.url = url; }

    @Override
    public String toString() {
        return "HotSong{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", author='" + author + '\'' +
                ", cover='" + cover + '\'' +
                ", hash='" + hash + '\'' +
                ", rank=" + rank +
                ", album='" + album + '\'' +
                ", duration='" + duration + '\'' +
                ", lyrics='" + lyrics + '\'' +
                '}';
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        dest.writeString(id);
        dest.writeString(name);
        dest.writeString(author);
        dest.writeString(cover);
        dest.writeString(hash);
        dest.writeInt(rank);
        dest.writeString(album);
        dest.writeString(duration);
        dest.writeString(lyrics);
        dest.writeString(url);
    }
}